﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Acoris.Input
{

#if NETFX_DESKTOP || WINDOWS_WPF

    using System.Security;
    using System.Runtime.InteropServices;

    #region NATIVE Wrapper

    [
        ComImport,
        SecurityCritical,
        SuppressUnmanagedCodeSecurity,
        Guid("AD5A0F41-ED1B-4675-9D9F-9A530C0E8FD0"),
        InterfaceType(ComInterfaceType.InterfaceIsIUnknown)
    ]
    public interface ITfInputProcessorProfiles
    {
        /// <summary>
        /// Sets the active text service for a specific language
        /// </summary>
        /// <param name="rclsid">激活指定的CLSID文本服务</param>
        /// <param name="langid">包含LANGID value that specifies which language to set the default profile for.如果不是当前激活的语言该方法调用会失败</param>
        /// <param name="guidProfiles">Contains a GUID value that identifies the language profile to make active</param>
        /// <returns></returns>
        int ActivateLanguageProfile(ref Guid rclsid, ref Guid langid, ref Guid guidProfiles);

        /// <summary>
        /// Creates a language profile that consists of a specific text service and a specific language identifier
        /// </summary>
        /// <param name="rclsid">Contains the text service CLSID</param>
        /// <param name="langid">Contains a LANGID value that specifies the language identifier of the profile that the text service is added to. If this contains -1, the text service is added to all languages</param>
        /// <param name="guidProfile">Contains a GUID value that identifies the language profile. This is the value obtained by ITfInputProcessorProfiles::GetActiveLanguageProfile when the profile is active</param>
        /// <param name="pchDesc">Pointer to a WCHAR buffer that contains the description string for the text service in the profile. This is the text service name displayed in the language bar</param>
        /// <param name="ccDesc">Contains the length, in characters, of the description string in pchDesc. If this contains -1, pchDesc is assumed to be a NULL-terminated string</param>
        /// <param name="pchIconFile">Pointer to a WCHAR buffer that contains the path and file name of the file that contains the icon to be displayed in the language bar for the text service in the profile. This file can be an executable (.exe), DLL (.dll) or icon (.ico) file.This parameter is optional and can be NULL.In this case, a default icon is displayed for the text service</param>
        /// <param name="cchFile">Contains the length, in characters, of the icon file string in pchIconFile. If this contains -1, pchIconFile is assumed to be a NULL-terminated string. This parameter is ignored if pchIconFile is NULL</param>
        /// <param name="uIconIndex">Contains the zero-based index of the icon in pchIconFile to be displayed in the language bar for the text service in the profile. This parameter is ignored if pchIconFile is NULL</param>
        /// <returns></returns>
        int AddLanguageProfile(ref Guid rclsid, ref Guid langid, ref Guid guidProfile, string pchDesc, ulong ccDesc, string pchIconFile, ulong cchFile, ulong uIconIndex);

        /// <summary>
        /// Sets the currently active language
        /// </summary>
        /// <param name="langid">Contains the LANGID of the language to make active</param>
        /// <returns></returns>
        int ChangeCurrentLanguage(ref Guid langid);

        /// <summary>
        /// Enables or disables a language profile for the current user
        /// </summary>
        /// <param name="rclsid">Contains the CLSID of the text service of the profile to be enabled or disabled.</param>
        /// <param name="langid">Contains a LANGID value that specifies the language of the profile to be enabled or disabled.</param>
        /// <param name="guidProfile">Contains a GUID value that identifies the profile to be enabled or disabled.</param>
        /// <param name="fEnable">Contains a BOOL value that specifies if the profile will be enabled or disabled. If this contains a nonzero value, the profile will be enabled. If this contains zero, the profile will be disabled.</param>
        /// <returns></returns>
        int EnableLanguageProfile(ref Guid rclsid, ref Guid langid, ref Guid guidProfile, ref bool fEnable);

        /// <summary>
        /// Enables or disables a language profile by default for all users
        /// </summary>
        /// <param name="rclsid">Contains the CLSID of the text service of the profile to be enabled or disabled.</param>
        /// <param name="langid">Contains a LANGID value that specifies the language of the profile to be enabled or disabled.</param>
        /// <param name="guidProfile">Contains a GUID value that identifies the profile to be enabled or disabled.</param>
        /// <param name="fEnable">Contains a BOOL value that specifies if the profile is enabled or disabled. If this contains a nonzero value, the profile is enabled. If this contains zero, the profile is disabled.</param>
        /// <returns></returns>
        int EnableLanguageProfileByDefault(ref Guid rclsid, ref Guid langid, ref Guid guidProfile, bool fEnable);

        /// <summary>
        /// Obtains an enumerator that contains the class identifiers of all registered text services
        /// </summary>
        /// <param name="ppEnum">Pointer to an IEnumGUID interface pointer that receives the enumerator object. The enumerator contains the CLSID for each registered text service. The caller must release this object when it is no longer required</param>
        /// <returns></returns>
        int EnumInputProcessorInfo(out Guid ppEnum);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="langid">Contains a LANGID value that specifies the language to obtain an enumerator for.</param>
        /// <param name="ppEnum">Pointer to an IEnumTfLanguageProfiles interface pointer that receives the enumerator object.</param>
        /// <returns></returns>
        int EnumLanguageProfiles(ref Guid langid, out IEnumTfLanguageProfiles ppEnum);
    }

    public interface IEnumTfLanguageProfiles
    {

    }
    #endregion

#endif

    partial class TextInputService : IDisposable
    {


#if NETFX_DESKTOP || WINDOWS_WPF

        public const int S_OK = 0;
        public const int E_FAIL = 0;
        public const int E_INVALIDARG = 0;
        public const int E_OUTOFMEMORY = 0;
        public const int E_UNEXPECTED = 0;

        public TextInputService()
        {

        }
#endif

        public void Dispose()
        {
#if NETFX_DESKTOP || WINDOWS_WPF

#elif NETFX_CORE || WINDOWS_UWP
#endif
        }
    }
}
